package com.hoodemia.ui;

import net.code.btalk.ui.Constants;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.component.ButtonField;

public class StandardButton extends ButtonField {
	private final static int MAX_HEIGHT = 40;
	
	public final static int PADDING_SMALL = 0;
	public final static int PADDING_MEDIUM = 1;
	public final static int PADDING_LARGE = 2;
	
	public StandardButton(String label, long style, int paddingSize) {
		super(label, style);
		
		switch (paddingSize) {
		case PADDING_SMALL:
			this.setPadding(0, 30, 0, 30);
			break;
		case PADDING_MEDIUM:
			this.setPadding(5, 40, 5, 40);
			break;
		case PADDING_LARGE:
			this.setPadding(10, 50, 10, 50);
			break;
		}
		
		this.setFont(Font.getDefault().derive(Font.BOLD));

		this.setBorder(ButtonField.VISUAL_STATE_NORMAL,
				Constants.SIMPLE_GRAY_BORDER, true);
		this.setBorder(ButtonField.VISUAL_STATE_FOCUS,
				Constants.SIMPLE_ORANGE_BORDER, true);
		this.setBorder(ButtonField.VISUAL_STATE_ACTIVE,
				Constants.SIMPLE_ORANGE_BORDER, true);

		
		this.setBackground(ButtonField.VISUAL_STATE_NORMAL,
				Constants.BUTTON_BACKGROUND_GREY_GRADIENT);
		this.setBackground(ButtonField.VISUAL_STATE_FOCUS,
				Constants.BUTTON_BACKGROUND_BLUE_GRADIENT);
	}

	public int getPreferredHeight() {
		// TODO Auto-generated method stub
		return MAX_HEIGHT;
	}
	
	protected void layout(int width, int height) {
		// TODO Auto-generated method stub
		super.layout(this.getPreferredWidth(), this.getPreferredHeight());
		super.setExtent(this.getPreferredWidth(), this.getPreferredHeight());
		this.setExtent(this.getPreferredWidth(), this.getPreferredHeight());
	}

}
